Skip to content

fix: sqlframe false positives in compliance checks#2011

Merged
FBruzzesi merged 4 commits intonarwhals-dev:mainfrom
camriddell:fix-sqlframe-order-dependent
Feb 14, 2025
Merged

fix: sqlframe false positives in compliance checks#2011
FBruzzesi merged 4 commits intonarwhals-dev:mainfrom
camriddell:fix-sqlframe-order-dependent

Conversation

@camriddell
Copy link
Member

@camriddell camriddell commented Feb 14, 2025

What type of PR is this? (check all applicable)

  • 💾 Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 🔧 Optimization
  • 📝 Documentation
  • ✅ Test
  • 🐳 Other

Related issues

  • Related issue #<issue number>
  • Closes #<issue number>

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

In the narwhals.from_native function, sqlframe had to be explicitly checked before the is_compliant* checks due to false positives from hasattr(sqlframe_df, "__narwhals_dataframe__").

  1. Instead we can use inspect.getattr_static (thanks for the suggestion @dangotbanned) to avoid this addition and we can move the sqlframe specific code to be in line with the other backends.

  2. I also added a test to ensure sqlframe cases are handled properly.

  3. I removed a test that will break in the future, this test was passing due to a side effect caused by hasattr on a pandas DataFrame enabling the use of nonhashable values as column names (raised as an issue in pandas BUG: Index.drop_duplicates() is inconsistent for unhashable values pandas-dev/pandas#60925)

@camriddell camriddell changed the title fix: compliance checks fail on sqlframe fix: sqlframe false positives in compliance checks Feb 14, 2025
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcoGorelli for the coverage is there a preference among

  1. Add sqlframe to the pytest GitHub CI
  2. Remove this test
  3. pragma: nocover the tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, I am taking a look for how to fully support sqlframe - it's still missing a few features (not many) to pass all our tests. I would say that for now it's ok to pragma: no cover it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely interested in testing sqlframe in CI, last time i checked it was too far to being passing - but they've resolved a lot of issues recently, so if we can run them in ci now then that would be great

else for now we can no cover the test

Copy link
Member

@FBruzzesi FBruzzesi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @camriddell 🚀 Left a couple of suggestion and (maybe) addressed your question

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, I am taking a look for how to fully support sqlframe - it's still missing a few features (not many) to pass all our tests. I would say that for now it's ok to pragma: no cover it

)

# SQLFrame
# This one needs checking before extensions as `hasattr` always returns `True`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not applicable anymore 😉

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're a magician 🪄

thanks! this may fix a cudf.pandas issue too!

@MarcoGorelli
Copy link
Member

pending on #2011 (comment) 😉

@camriddell
Copy link
Member Author

failing downstream tests seem to be unrelated. I know that panel just released a new version which may have broken marimo if they don't have an upperbound version constraint.

@FBruzzesi
Copy link
Member

Cool thanks! pointblank also just merged a new feature, we can update its dependency on another PR

@FBruzzesi FBruzzesi merged commit 3f174a3 into narwhals-dev:main Feb 14, 2025
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants